<?php
namespace app\api\controller\v2;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/7/23
 * Time: 16:24
 * 日志类
 */
use think\facade\Db;

class LogController
{
    //添加日志
    public function add_log($data,$l_id = 0){
        if($l_id==0){//新增
            $json_data = json_encode($data,JSON_UNESCAPED_UNICODE);
            $ip = $_SERVER["REMOTE_ADDR"];
            $interface = $_SERVER['REQUEST_URI'];
            $add_time = $_SERVER['REQUEST_TIME'];
            $list = [
                'yny_post_data'=>$json_data,
                'interface'=>$interface,
                'post_ip'=>$ip,
                'addtime'=>$add_time
            ];
            $log_id = Db::name('yny_log')->insertGetId($list);
            return $log_id;
        }else{
            $wx_post_data = json_encode($data,true);
            //更新log表
            Db::name('yny_log')->where('id',$l_id)->update(['wx_post_data'=>$wx_post_data]);
        }
    }
}